﻿//HttpUtils.cpp

#include "httputils.h"
#include <QDebug>
#include <QNetworkReply>

HttpUtils::HttpUtils(QObject *parent) : QObject(parent)
{
    manager = new QNetworkAccessManager(this);
    QObject::connect(manager, SIGNAL(finished(QNetworkReply*)),this, SLOT(replyFinished(QNetworkReply*)));
}

void  HttpUtils::connect(QString url){
    QNetworkRequest request;
    request.setUrl(QUrl(BASE_URL+url));
    manager->get(request);
}

void HttpUtils::replyFinished(QNetworkReply* reply){
    QString result =reply->readAll();
    emit replySignal(result);
}

HttpUtils::~HttpUtils(){
    delete manager;
}
